package com.teacher.mobile.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.teacher.common.CommonResult;
import com.teacher.pojo.dto.comment.CommentAddDto;
import com.teacher.pojo.dto.comment.CommentDto;
import com.teacher.pojo.dto.comment.CommentUpdateDto;
import com.teacher.pojo.vo.comment.CommentVo;
import com.teacher.security.entity.annotation.WhiteApi;
import com.teacher.service.ICommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jiangzhuohang
 * @since 2024-03-14
 */
@RestController
@RequestMapping("/comment")
@Api(tags = "评价接口")
public class CommentController {
    
    @Autowired
    private ICommentService iCommentService;


    @WhiteApi
    @ApiOperation("后台获取评价列表(分页) ")
    @GetMapping("/getComment")
    public CommonResult getComment(CommentDto pageVo){
        IPage<CommentVo> commentPageData = iCommentService.getCommentPageData(pageVo);
        return CommonResult.success(commentPageData);
    }


    @PostMapping("addComment")
    @ApiOperation("添加评价 (废弃) ")
    public CommonResult addComment(@RequestBody CommentAddDto dto) {
        return iCommentService.addComment(dto);
    }

    @DeleteMapping("/deleteCommentById")
    @ApiOperation("通过评价 id批量删除评价 ")
    public CommonResult deleteCommentById(@RequestBody List<Long> list) {
        return  iCommentService.deleteComment(list);
    }
    @PostMapping("/updateCommentById")
    @ApiOperation("用户通过评价id来评价 ")
    public CommonResult updateCommentById(@RequestBody CommentUpdateDto updateDto) {
        return iCommentService.updateComment(updateDto);
    }
}

